package progress.exa29_2.part1;

import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;

public class InetAddressStudy {

    public static void main(String[] args) {
        try{
            //创建套接字
            Socket socket = new Socket("www.baidu.com",80);
            InetAddress inetAddress = socket.getInetAddress();
            System.out.println("Server's host name is: "+inetAddress.getHostName());
            System.out.println("Server's IP Address name is: "+inetAddress.getHostAddress());

            InetAddress address = InetAddress.getByName("www.baidu.com");
            System.out.println("Server's host name is: "+address.getHostName());
            System.out.println("Server's IP Address name is: "+address.getHostAddress());
        }catch(IOException ex) {
            ex.printStackTrace();
        }
    }

}
